<div class="ajaxLoading">
<img src='<?php echo $engineReturn['admin_template']?>css/images/loading.gif' width="50" align="middle" />
</div>
<div id="containerInsertForm" style="display:none">
<h2></h2> 
<a href='#' class='aNav' id='view_data_id'>View Data</a>
<form id="frmEngineInsert" name="frmEngineInsert" method="post" action="<?php echo $baseUrlSave;?><?php echo $otority;?>/engine/<?php echo $engineReturn['modulename'];?>/normal/insert_cross/<?php echo $engineReturn['idEdit']."";?>" enctype="multipart/form-data">
<table class="table" width="100%">
<?php
//echo "<pre>";
//print_r($engineReturn);
$ok = false;
if(is_array	($engineReturn['msg']))
foreach($engineReturn['msg'] as $msg)
{
	echo "<div class='inlineMessage'><a href='#".$msg[1]."'>".$msg[0]."</a></div>";
	if($msg[0]=='sukses')
		$ok = true;
}
foreach($engineReturn['field'] as $key=>$row)
{
	if($row['value']==$engineReturn['idEdit'])
	{
		$value	=	$row['real_value'];
		echo "<tr>";
			echo "<td  width='25%'>".$row['text']."</td>";
			echo "<td>";
			switch($row['input'])
			{
				case "text":
						echo "<input type='text' id='".$row['name']."' name='".$row['name']."' class='rejectInput engineInput ".(($row['attr']['maxlength']==10)?"datepicker":"")."' size='".$row['attr']['size']."' maxlength='".$row['attr']['maxlength']."' title='Input Text' value='".$value."'>";
				break;
				case "text_area":
						echo "<textarea id='".$row['name']."' name='".$row['name']."' class='rejectInput engineInput' cols='".$row['attr']['cols']."' rows='".$row['attr']['rows']."' title='Input Text'>".$value."</textarea>";
				break;
				case "radio":
						if(is_array($value))
							$value = $value[0];
						echo "<table>";
						foreach($row['real_source'] as $rs)
						{
							echo "<tr><td>";
								echo "<input type='radio' id='".$row['name']."' name='".$row['name']."' value='".$rs[0]."' ".(($value==$rs[0])?"checked='checked'":"")."> ".(isset($rs[1])?$rs[1]:$rs[0]);
							echo "</td></tr>";
						}
						echo "</table>";
				break;
				case "select":
						echo "<select id='".$row['name']."' name='".$row['name']."'>";
						echo "<option value=''>-".$row['text']."-</option>";
						foreach($row['real_source'] as $rs)
						{
								echo "<option value='".$rs[0]."' ".(($value==$rs[0])?"selected='selected'":"")."> ".(isset($rs[1])?$rs[1]:$rs[0])."</option>";
						}
						echo "</select>";
				break;
				case "image":
					echo "<div>
							<input type='file' id='".$row['name']."' name='".$row['name']."' class='engineInput' size='".$row['attr']['size']."' title='Input Image'>
						</div>";
					if(isset($value[0]) && ($value[0]!=''))
					{
						echo "<div id='countainer-imageitem-".$row['name']."' id='countainer-imageitem-".$row['name']."' class='defContainerImage'>";
							echo "<img src='".$value[0]."'/>";
//							echo "<br><input type='checkbox' ".(($value[2])?"checked='checked'":"")." id='input-image-".$row['name']."' name='input-image-".$row['name']."' value='input-image-".$row['name']."'> Delete Image";
						echo "</div>";
					}
				break;
				case "simple_table":
						echo "<select id='".$row['name']."' name='".$row['name']."'>";
						echo "<option value=''>-".$row['text']."-</option>";
						foreach($row['real_source'] as $rs)
						{
								echo "<option value='".$rs['idRec']."'".(($value==$rs['idRec'])?"selected='selected'":"")."> ".$rs['dataRec']."</option>";
						}
						echo "</select>";
				break;
			}
			if(is_array($row['note']))
			foreach($row['note'] as $r)
			{
				echo "<br />".$r;
			}
			echo "</td>";
		echo "</tr>";
	}
}

?>
	<tr>
    	<td colspan="2">
        	<input type="hidden" id="init" name="init" value="save">
        	<input type="submit" value="Save" class="button" id="submitInsert">
			<script type='text/javascript'>
				$(document).ready(function(){
					$('#frmEngineInsert').submit(function(){
						if(!confirm("Are You sure?"))
							return false;
					});
				});
			</script>
        </td>
    </tr>
</table>
</form>
</div>
<script type="text/javascript">
	$('#containerInsertForm').delay(100).show('slow');
	$('#view_data_id').navigateToView({
		url 			: '<?php echo $baseUrlSave;?><?php echo $otority;?>/engine/<?php echo $engineReturn['modulename'] ?>/ajax/view/all/',
		div_form 		: 'containerInsertForm',
		div_loading 	: 'ajaxLoading',
	});
<?php
	if($ok)
		echo "$('#view_data_id').click();";
?>

</script>